
import React from 'react';
import {Card,Row,Col,Button,Icon,message } from 'antd';
import moment from 'moment';
import {Link} from 'react-router-dom';
import PureRenderMixin from 'react-addons-pure-render-mixin';

import LeftMenu from 'component/leftmenu/index.jsx';
import HeadImgContent from 'component/headimgcontent/index.jsx';
import LeftMenuItem from 'component/leftmenuitem/index.jsx';


import MMUtile from 'util/mm.jsx';
import User from 'service/user-service.jsx';
const _mm = new MMUtile();
const _user = new User();

import './style.css';

class BindUser extends React.Component{
	constructor(props){
		super(props);
		this.shouldComponentUpdate = PureRenderMixin.shouldComponentUpdate.bind(this);
		this.state = {
			items:[{'name':'修改头像','actived':false,'link':'/update-head-img','icon':'smile-o'},
			{'name':'基本资料','actived':true,'link':'/user-base','icon':'solution'},
			{'name':'详细资料','actived':false,'link':'/user-link','icon':'link'},
			{'name':'设置昵称','actived':false,'link':'/user-nick','icon':'tool'},
			{'name':'账号绑定','actived':true,'link':'','icon':'lock'}],
			isbindwechat:false,
			isbindqq:false
		}
	}
	componentDidMount(){
		_user.wechatOrQqIsBind().then((res)=>{
			this.setState({
				isbindwechat:res.wechat==0?true:false,
				isbindqq:res.qq==0?true:false
			})
		},(errMsg)=>{
			_mm.errorTips(errMsg)
		})
	}
	cancalBindWechat(e){
		//取消绑定微信
		_user.cancalWechat().then((res)=>{
			this.setState({
				isbindwechat:false
			})
		},(errMsg)=>{
			_mm.errorTips(errMsg)
		})
	}
	render(){
		return(
			<div>
				<Row gutter={24}>
					<Col span={7}>
		        <Card bordered={true} className="itemminheight"><LeftMenuItem items={this.state.items}></LeftMenuItem></Card>
		      </Col>
		      <Col span={17}>
						<Card title="绑定第三方账号" style={{minHeight:'400px'}} bordered={false}>
							<Row style={{marginTop:'100px'}}>
								{
									!this.state.isbindqq
									?
									<Col span={12} style={{textAlign:'center',cursor: 'pointer'}} >
										<Icon type="qq" className="qqicon" />
										<div>点击绑定QQ</div>
									</Col>
									:
									<Col span={12} style={{textAlign:'center',cursor: 'pointer'}} >
										<Icon type="qq" className="qqicon" />
										<div>点击绑定QQ</div>
									</Col>
								}
								{
									!this.state.isbindwechat
									?
									<Col span={12} style={{textAlign:'center',cursor: 'pointer'}} >
										<a href="http://sso.rnpig.com/user/afterLoginBindWechat.act"><Icon type="wechat" className="wecharticon"  /></a>
										<div>点击绑定微信</div>
									</Col>
									:
									<Col span={12} style={{textAlign:'center',cursor: 'pointer'}} onClick={this.cancalBindWechat.bind(this)}>
										<Icon type="wechat" className="wecharticon"  />
										<div>取消绑定</div>
									</Col>
								}
							</Row>
						</Card>
		      </Col>
				</Row>
			</div>
		)
	}
}
export default BindUser